//
//  Building.cpp
//  IsoCplus
//
//  Created by zhouzhanglin on 15/9/17.
//
//

#include "Building.h"

USING_NS_CC;

Building* Building::create(unsigned int size,unsigned int spanX ,unsigned int spanZ)
{
    Building *o = new Building();
    if(o&&o->init(size,spanX,spanZ)){
        o->autorelease();
        return o;
    }
    CC_SAFE_DELETE(o);
    return nullptr;
}

bool Building::init(unsigned int size,unsigned int spanX,unsigned int spanZ)
{
    IsoObject::init(size, spanX, spanZ);
    
    _container = Node::create();
    addChild(_container);
    
    createSkin();
    
    return true;
}

void Building::createSkin()
{
    _container->removeAllChildren();
    if(getSpanX()==1){
        auto sp = Sprite::create("isoRes/stove.png");
        sp->setPosition(-6,0);
        _container->addChild(sp);
    }else if(getSpanX()==2){
        auto sp = Sprite::create("isoRes/host.png");
        sp->setPosition(0,-54);
        _container->addChild(sp);
    }
}

Building::~Building()
{
    _container = nullptr;
}